<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

    <div class="layui-card">
              <div class="layui-tab layui-tab-brief layadmin-latestData">
                <div class="layui-tab-content">
                  <div class="layui-tab-item layui-show">
                    <div class="layui-card">
                      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                        <div class="layui-form-item">
                          <div class="layui-inline">
                            <label class="layui-form-label"><!--{$lang.page.table.account}--></label>
                            <div class="layui-input-inline">
                              <input type="text" name="username" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                            </div>
                          </div>
                          <div class="layui-inline">
                            <label class="layui-form-label"><!--{$lang.page.table.ordernum}--></label>
                            <div class="layui-input-inline">
                              <input type="text" name="acode" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                            </div>
                          </div>
                          <div class="layui-inline">
                            <label class="layui-form-label"><!--{$lang.page.table.agent}--></label>
                            <div class="layui-input-inline">
                              <select name="agent" id="agent" >
                                <option value=""><!--{$lang.page.public.select}--></option>
                                <!--{foreach from=$agent item=item}-->
                                <option value="<!--{$item.aid}-->" ><!--{$item.username}--></option>
                                <!--{/foreach}-->
                              </select>
                            </div>
                          </div>
                          <div class="layui-inline">
                            <label class="layui-form-label"><!--{$lang.page.table.status}--></label>
                            <div class="layui-input-inline">
                              <select name="status">
                                <option value=""><!--{$lang.page.public.select}--></option>
                                <option value="1" ><!--{$lang.page.table.tradeings}--></option>
                                <option value="2" ><!--{$lang.page.table.finish}--></option>
                              </select>
                            </div>
                          </div>
                          <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="allsearch">
                              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                          </div>
                        </div>
                      </div>
                    </div>   
 
                    <table id="datalist" lay-filter="datalist"></table>
                    <script type="text/html" id="toolbartop">
                        <button class="layui-btn layui-btn-sm" lay-event="redatalist"><!--{$lang.page.public.refresh}--></button>
                        <button class="layui-btn layui-btn-sm" id="rall" lay-event="all"><!--{$lang.page.table.all}--></button>
                        <button class="layui-btn layui-btn-sm" id="rday" lay-event="day"><!--{$lang.page.table.today}--></button>
                        <button class="layui-btn layui-btn-sm" id="ryesterday" lay-event="yesterday"><!--{$lang.page.table.yestoday}--></button>
                        <button class="layui-btn layui-btn-sm" id="rweek" lay-event="week"><!--{$lang.page.table.toweek}--></button>
                        <button class="layui-btn layui-btn-sm" id="rmonth" lay-event="month"><!--{$lang.page.table.tomonth}--></button>
                        <button class="layui-btn layui-btn-sm" id="rmonthb" lay-event="monthb"><!--{$lang.page.table.prevmonth}--></button>
                        <div class="layui-btn layui-btn-green layui-btn-sm" id="feesum"></div>
                        <div class="layui-btn layui-btn-danger layui-btn-sm" id="winsum"></div>
                        <div class="layui-btn layui-btn-yellow layui-btn-sm" id="losssum"></div>
                        <div class="layui-btn layui-btn-sm" id="xiadansum"></div>
                    </script>
                    <script type="text/html" id="zizeng">{{d.LAY_TABLE_INDEX+1}}</script>
                    <script type="text/html" id="alltool">
                        <a class="layui-btn layui-btn-xs show" data-set="{{d.id}}"><!--{$lang.page.table.view}--></a>
                        <a class="layui-btn layui-btn-xs disk" data-set="{{d.id}}"><!--{$lang.page.public.control}--></a>
                    </script>
                  </div>

                </div>
              </div>
    </div>

<script src="/static/lay/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
       base: '/static/lay/' //静态资源所在路径
    }).extend({
         roleper:'lib/roleper'
         , xadmin:'lib/xadmin'
         , lang:'lib/lang'
       }).use(['roleper', 'xadmin', 'table', 'lang'], function () {

            var $ = layui.$
            , form = layui.form
            , table = layui.table
            , roleper = layui.roleper
            , toolbar = roleper.showtool({mid:50,per:[{sys:'disk'},{sys:'show'}]}) ? false : true; //根据权限是否显示操作列
            var lang=layui.lang.init();
            table.render({
            elem: '#datalist'
            , height: 'auto'
            , url: 'all' //数据接口
            , method: 'post'
            , page: true //开启分页
            , limit: 10
            , toolbar: '#toolbartop'
            , defaultToolbar: ['filter', 'exports', 'print']
            , cols: [[ //表头
                {field: 'zizeng', title: function(){ return lang.serial }, align: "center", fixwidth: true, width: 80, templet:'#zizeng'},
                {field: 'order_no', align: "center", width: 180, title: function(){ return lang.ordernum }},
                {field: 'createtime', align: "center", width: 160, title: function(){ return lang.createtime }},
                {field: 'username', title: function(){ return lang.account }},
                {field: 'realname', title: function(){ return lang.realname }},
                // {field: 'protype', title: '停损停利', align: "center",
                //   templet: function(d) {
                //       if (d.protype == 1) {
                //             return '<button class="layui-btn layui-btn-green layui-btn-xs">否</button>';
                //         } else if(d.protype == 2) {
                //             return '<button class="layui-btn layui-btn-danger layui-btn-xs">是</button>';
                //         } else {
                //             return '<button class="layui-btn layui-btn-xs">错误</button>';
                //         }
                //   }
                // },
                {field: 'waitbuy', title: function(){ return lang.buying+lang.status }, align: "center",
                  templet: function(d) {
                      if (d.waitbuy == 1) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.buyed+'</button>';
                        } else if(d.waitbuy == 2) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.bebuy+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-xs">'+lang.error+'</button>';
                        }
                  }
                },
                {field: 'proname', title: function(){ return lang.product }},         
                // {field: 'money', title: '盈亏金额', align: "center",
                //   templet: function(d) {
                //       return (Number(d.money)).toFixed(2);
                //   }
                // },
                {field: 'updown', title: function(){ return lang.direction }, align: "center",
                  templet: function(d) {
                       if (d.updown == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.buyup+'</button>';
                        } else if(d.updown == 2) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.buydown+'</button>';
                        }
                  }
                },
                {field: 'type', title: function(){ return lang.type }, align: "center",
                  templet: function(d) {
                       if (d.type == 2) {
                            return '<button class="layui-btn layui-btn-xs">'+lang.virtual+'</button>';
                        } else if(d.type == 1) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.tradeing+'</button>';
                        }
                  }
                },
                {field: 'status', title: function(){ return lang.tradeing+lang.status }, align: "center",
                  templet: function(d) {
                       if (d.status == 1) {
                            return '<button class="layui-btn layui-btn-xs">'+lang.tradeings+'</button>';
                        } else if(d.status == 2) {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.finish+'</button>';
                        } else if(d.status == 3) {
                            return '<button class="layui-btn layui-btn-yellow layui-btn-xs">'+lang.settleing+'</button>';
                        } else if(d.status == 4) {
                            return '<button class="layui-btn layui-btn-disabled layui-btn-xs">'+lang.settled+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.other+'</button>';
                        }
                  }
                },
                {field: 'rstatus', title: function(){ return lang.warn+lang.status }, align: "center",
                  templet: function(d) {
                       if (d.rstatus == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.warnline+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.normal+'</button>';
                        }
                  }
                },
                {field: 'reset', title: function(){ return lang.calculate+lang.status }, align: "center",
                  templet: function(d) {
                       if (d.reset == 1) {
                            return '<button class="layui-btn layui-btn-danger layui-btn-xs">'+lang.error+'</button>';
                        } else {
                            return '<button class="layui-btn layui-btn-green layui-btn-xs">'+lang.normal+'</button>';
                        }
                  }
                },
                {fixed: '', title: function(){ return lang.operation }, width: 200, align: 'center', toolbar: '#alltool', hide:toolbar}
            ]],
            done: function(d) {
                layer.closeAll('loading');
                roleper.render({mid:50,per:[{sys:'show',method:'open',law:'1200*638',full:true},{sys:'disk',method:'open',law:'1300*638',full:true}],full:false});//law 设置长宽，full是否全屏，par父窗口打开
                $('#xiadansum').html(lang.platform+lang.mloss+"："+d.sum.money); // 下单金额
                $('#feesum').html(lang.fee+"："+d.sum.fee); // 手续费金额
                $('#winsum').html(lang.win+"："+d.sum.win); // 客赢金额
                $('#losssum').html(lang.loss+"："+d.sum.loss); // 客损金额
            }
            });

        //监听搜索
        form.on('submit(allsearch)', function(data){
          var field = data.field;
          //执行重载
           table.reload('datalist', {
            where: field,
            page: {
              curr: 1 //重新从第 1 页开始
            }
           });
        });

        table.on('toolbar(datalist)', function(obj){
            var element = $(".layui-btn-rech").attr("id");
            var agent = $("#agent option:selected").val();
            switch(obj.event){
                    case 'redatalist':
                        //执行重载
                        table.reload('datalist');
                        $('#'+element).addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'all':
                        //执行重载
                        table.reload('datalist', {
                            where: {'agent':agent,'username':$('input[name="username"]').val(),'acode':$('input[name="acode"]').val(),'time':1},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#rall').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'day':
                        //执行重载
                        table.reload('datalist', {
                            where: {'agent':agent,'username':$('input[name="username"]').val(),'acode':$('input[name="acode"]').val(),'time':2},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#rday').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'yesterday':
                        //执行重载
                        table.reload('datalist', {
                            where: {'agent':agent,'username':$('input[name="username"]').val(),'acode':$('input[name="acode"]').val(),'time':3},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#ryesterday').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'week':
                        //执行重载
                        table.reload('datalist', {
                            where: {'agent':agent,'username':$('input[name="username"]').val(),'acode':$('input[name="acode"]').val(),'time':4},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#rweek').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'month':
                        //执行重载
                        table.reload('datalist', {
                            where: {'agent':agent,'username':$('input[name="username"]').val(),'acode':$('input[name="acode"]').val(),'time':5},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#rmonth').addClass('layui-btn-danger layui-btn-rech')
                    break;
                    case 'monthb':
                        //执行重载
                        table.reload('datalist', {
                            where: {'agent':agent,'username':$('input[name="username"]').val(),'acode':$('input[name="acode"]').val(),'time':6},
                            page: {
                              curr: 1 //重新从第 1 页开始
                            }
                        });
                        $('#rmonthb').addClass('layui-btn-danger layui-btn-rech')
                    break;
                };
        });      
            
    });
</script>
</body>
</html>

